home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-16 | 6.8 KB | 286 lines | [TEXT/KAHL] |
- /******************************************************************************
- x_CApp.cp
-
- CApp "Lower-Layer" Application Class
-
- Copyright © 1996 Dan Crevier. All rights reserved.
-
- Generated by Visual Architectâ„¢ 10:48 AM Sun, Jun 16, 1996
-
- This file is rewritten each time you generate code. You should not
- make changes to this file; changes should go in the CApp.cp
- file, instead.
-
- If you want to change how Visual Architect generates this file, you can
- change the template for this file. It is "_App_cp" in the Visual Architect
- Templates folder.
-
- ******************************************************************************/
-
- #include "x_CApp.h"
-
- #include "CApp.h"
-
- #include "References.h"
- #include "CMain.h"
- #include "CAbout.h"
- #include <CBartender.h>
- #include <Commands.h>
- #include <CDesktop.h>
- #include <CFile.h>
- #include <CFWDesktop.h>
- #include <CList.h>
- #include <Packages.h>
- #include <TBUtilities.h>
- #include <TCLForceReferences.h>
-
- #include "CAbout.h"
- #include "CMain.h"
- #include "CVAWASTEDlgText.h"
- #include "CVAWASTEText.h"
-
- extern OSType gSignature; /* Creator for Application's files */
- extern CBartender *gBartender; /* Manages all menus */
- extern CDesktop *gDesktop; /* The visible Desktop */
-
- // Define symbols for commands handled by this class
- // Prevents a recompile every time any command changed.
-
- #define cmdAbout 256
-
-
- TCL_DEFINE_CLASS_M1(x_CApp, CApplication);
-
- /**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
-
-
- /******************************************************************************
- Ix_CApp
-
- Initialize an Application.
- ******************************************************************************/
-
- void x_CApp::Ix_CApp(short extraMasters, Size aRainyDayFund,
- Size aCriticalBalance, Size aToolboxBalance)
-
- {
- IApplication(extraMasters, aRainyDayFund, aCriticalBalance, aToolboxBalance);
- }
-
-
- /******************************************************************************
- SetUpFileParameters {OVERRIDE}
-
- Specify the kinds of files your application opens
- ******************************************************************************/
-
- void x_CApp::SetUpFileParameters()
- {
- CApplication::SetUpFileParameters();
-
- // File types as defined in CApp.h
-
- sfNumTypes = kNumFileTypes;
- sfFileTypes[0] = kFileType1;
- sfFileTypes[1] = kFileType2;
- sfFileTypes[2] = kFileType3;
- sfFileTypes[3] = kFileType4;
- gSignature = 'wVAp';
- }
-
-
- /******************************************************************************
- SetUpMenus {OVERRIDE}
-
- Set up the menus after first creating any floating/tearoff
- windows. The latter must be done before the bartender inits.
- ******************************************************************************/
-
- void x_CApp::SetUpMenus()
- {
-
-
- CApplication::SetUpMenus();
-
- }
-
-
- /******************************************************************************
- ForceClassReferences {OVERRIDE}
-
- Reference classes that might do object I/O.
- ******************************************************************************/
-
- void x_CApp::ForceClassReferences(void)
-
- {
- CApplication::ForceClassReferences();
-
- /* From References.c */
- ReferenceStdClasses(); /* See template file Ref */
-
- TCL_FORCE_REFERENCE(CVAWASTEDlgText);
- TCL_FORCE_REFERENCE(CVAWASTEText);
- }
-
-
- /**** C O M M A N D M E T H O D S ****/
-
-
- /******************************************************************************
- DoCommand {OVERRIDE}
-
- Handle application commands
- ******************************************************************************/
-
- void x_CApp::DoCommand(long theCommand)
-
- {
- switch (theCommand)
- {
- case cmdAbout:
- DoCmdAbout();
- break;
-
- default:
- CApplication::DoCommand(theCommand);
- break;
- }
- }
-
-
- /******************************************************************************
- UpdateMenus {OVERRIDE}
-
- Enable menus which generate commands handled by this class.
- ******************************************************************************/
-
- void x_CApp::UpdateMenus()
-
- {
- CApplication::UpdateMenus();
-
- gBartender->EnableCmd(cmdAbout);
- }
-
-
- /******************************************************************************
- DoCmdAbout
-
- Respond to cmdAbout command.
- ******************************************************************************/
-
- void x_CApp::DoCmdAbout()
-
- {
- CAbout *alert;
-
- // Respond to command by opening a alert
-
- alert = TCL_NEW(CAbout,());
- alert->ICAbout(this);
-
- alert->DoModalDialog(cmdNull); /* cmdNull because dialog already knows */
- TCLForgetObject(alert);
- }
-
-
- /**** D O C U M E N T M E T H O D S ****/
-
-
- /******************************************************************************
- CreateDocument {OVERRIDE}
-
- Make a new document when user chooses New from file menu.
- This method is entirely generic except for the document class.
- ******************************************************************************/
-
- void x_CApp::CreateDocument()
-
- {
- CDocument *volatile theDocument = NULL;
-
- theDocument = TCL_NEW(CMain,());
- try_
- {
- ((CMain*) theDocument)->ICMain();
- theDocument->NewFile();
- }
- catch_all_()
- {
- TCLForgetObject(theDocument);
- throw_same_();
- }
- end_try_
- }
-
-
- /******************************************************************************
- OpenDocument {OVERRIDE}
-
- Open a document when user chooses Open from file menu.
- For multiple document types, this method assumes that each
- document is associated with a single file type.
- ******************************************************************************/
-
- void x_CApp::OpenDocument(SFReply *macSFReply)
-
- {
- CDocument *volatile theDocument = NULL;
-
- theDocument = TCL_NEW(CMain,());
- try_
- {
- ((CMain*) theDocument)->ICMain();
- theDocument->OpenFile(macSFReply);
- }
- catch_all_()
- {
- TCLForgetObject(theDocument);
- throw_same_();
- }
- end_try_
- }
-
-
-
-
- /******************************************************************************
- FileAlreadyOpen
-
- If file already in use return TRUE and bring owning document's
- window to the foreground. Sent from document before opening.
- ******************************************************************************/
-
- static Boolean EqualFile(CDirector *obj, long param)
- {
- FSSpec theFileSpec;
- CFile *theFile;
- FSSpec *theParam = (FSSpec*) param;
-
- if (member(obj, CDocument))
- {
- theFile = ((CDocument*)obj)->itsFile;
- if (theFile == NULL)
- return FALSE;
- theFile->GetFSSpec(&theFileSpec);
- return theFileSpec.vRefNum == theParam->vRefNum
- && theFileSpec.parID == theParam->parID
- && !IUEqualString(theFileSpec.name, theParam->name);
- }
- return FALSE;
- }
-
- Boolean x_CApp::FileAlreadyOpen(
- FSSpec *fileSpec)
-
- {
- CDirector *theDirector = NULL;
-
- if (itsDirectors) /* Search for matching file */
- theDirector = (CDirector*) itsDirectors->FindItem1(EqualFile, (long) fileSpec);
- if (theDirector) /* If find one, bring to front */
- theDirector->GetWindow()->Select();
- return theDirector != NULL; /* Tell caller */
- }
-